package net.minecraft.client.render.block;

import java.util.Map;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.BlockStateModel;
import net.minecraft.client.texture.Sprite;

@Environment(EnvType.CLIENT)
public class BlockModels {
	private Map<BlockState, BlockStateModel> models = Map.of();
	private final BakedModelManager modelManager;

	public BlockModels(BakedModelManager modelManager) {
		this.modelManager = modelManager;
	}

	public Sprite getModelParticleSprite(BlockState state) {
		return this.getModel(state).particleSprite();
	}

	public BlockStateModel getModel(BlockState state) {
		BlockStateModel blockStateModel = (BlockStateModel)this.models.get(state);
		if (blockStateModel == null) {
			blockStateModel = this.modelManager.getMissingModel();
		}

		return blockStateModel;
	}

	public BakedModelManager getModelManager() {
		return this.modelManager;
	}

	public void setModels(Map<BlockState, BlockStateModel> models) {
		this.models = models;
	}
}
